#pragma once
#include<iostream>
#include<stdio.h>
#include <vector>

using namespace std;

template<class T>
class Matrix
{
  
 public:
	 
	 Matrix(const int row,const int col)
	 {
		Row = row;
		Col = col;

		matrix_elements = new T*[Row];
		for (int i = 0;i < Row;i++)
		{
			matrix_elements[i] = new T[Col];
		}
	 }

	 ~Matrix()
	 {
		if (matrix_elements == nullptr) return;

		for (int i = 0;i < Row;i++)
		{
			delete[] matrix_elements[i];
		}

		delete[] matrix_elements;

	 }

	 bool Is_square()
	 {
		return Row == Col;
     }

	 void Print_matrix()
	 {
		for (int i = 0;i < Row;i++)
		{
			for (int j = 0;j < Col;j++)
			{
				cout << matrix_elements[i][j] << '\t';
			}
			cout << endl;
		}
	 }

	 Matrix<T> operator* (const Matrix<T>& product)
	 {
		Matrix<T> Result = Matrix(Row, Col);

		for (int i = 0; i < Row; i++)
		{
			for (int j = 0; j < Col; j++)
			{
				Result.matrix_elements[i][j] = 0;
				for (int k = 0; k < Col; k++)
				{
					Result.matrix_elements[i][j] += (matrix_elements[i][k] * product.matrix_elements[k][j]);
				}
			}
		}

		return Result;
	 }

	 bool operator==(const Matrix<T>& AnotherMatrix)
	 {
		return this->Row == AnotherMatrix.Row && this->Col == AnotherMatrix.Col;
	 }

public:

	 int Row;
	 int Col;

	 T** matrix_elements;
};

template<typename T>
class ColVector : public Matrix<T>
{
public:

	ColVector();

	void SortToRow();

public:

	T** ColSort = nullptr;
};

template<typename T>
class RowVector : public Matrix<T>
{
public:

	RowVector();

	void SortToRow();
};
